<template>
    <div class="home">
        <h1 class="art-font">欢迎使用页面设计应用。</h1>
        <div>
            <el-button @click="goBuilder"> H5 设计 </el-button>
            <el-button @click="goBuilderPc"> PC 设计 </el-button>
            <el-button @click="goBuilderWeb"> BS 设计 </el-button>
        </div>
        <div>
            <el-button @click="goH5(106)"> H5 页面设计1 </el-button>
            <el-button @click="goH5(1365)"> H5 页面设计2 </el-button>
            <el-button @click="goH5(667)"> H5 页面设计3 </el-button>
            <el-button @click="goPc(149)"> PC 页面设计1 </el-button>
        </div>

        <el-dialog title="页面设计" :visible.sync="show"
                   :fullscreen="true" custom-class="m-dialog-fullscreen m-dialog-fullscreen-nh"
                   :close-on-click-modal="false" :append-to-body="true">
            <builder v-if="show" :page-type="pageType" :in-page-id="pageId" @close="handleClose"></builder>
        </el-dialog>
    </div>
</template>

<script>
    import Builder from "./builder";

    export default {
        name: 'Home',
        data () {
            return {
                show: false,
                pageType: 1,    // 1, 2, 5
                pageId: null,
                jsonOptions: {
                    mode: 'tree',
                    modes: [ 'tree', 'code' ],
                    navigationBar: true,
                    mainMenuBar: true,
                    colorPicker: true,
                    timestampTag: true,
                    statusBar: true
                },
                jsonData: {
                    total: 25,
                    limit: 10,
                    skip: 0,
                    links: {
                        previous: undefined,
                        next: function () {},
                    },
                    data: [
                        {
                            id: '5968fcad629fa84ab65a5247',
                            firstname: 'Ada',
                            lastname: 'Lovelace',
                            awards: null,
                            known: [
                                'mathematics',
                                'computing'
                            ],
                            position: {
                                lat: 44.563836,
                                lng: 6.495139
                            },
                            description: `Augusta Ada King, Countess of Lovelace (née Byron; 10 December 1815 – 27 November 1852) was an English mathematician and writer,
            chiefly known for her work on Charles Babbage's proposed mechanical general-purpose computer,
            the Analytical Engine. She was the first to recognise that the machine had applications beyond pure calculation,
            and published the first algorithm intended to be carried out by such a machine.
            As a result, she is sometimes regarded as the first to recognise the full potential of a "computing machine" and the first computer programmer.`,
                            bornAt: '1815-12-10T00:00:00.000Z',
                            diedAt: '1852-11-27T00:00:00.000Z'
                        }, {
                            id: '5968fcad629fa84ab65a5246',
                            firstname: 'Grace',
                            lastname: 'Hopper',
                            awards: [
                                'Defense Distinguished Service Medal',
                                'Legion of Merit',
                                'Meritorious Service Medal',
                                'American Campaign Medal',
                                'World War II Victory Medal',
                                'National Defense Service Medal',
                                'Armed Forces Reserve Medal',
                                'Naval Reserve Medal',
                                'Presidential Medal of Freedom'
                            ],
                            known: null,
                            position: {
                                lat: 43.614624,
                                lng: 3.879995
                            },
                            description: `Grace Brewster Murray Hopper (née Murray; December 9, 1906 – January 1, 1992)
            was an American computer scientist and United States Navy rear admiral.
            One of the first programmers of the Harvard Mark I computer,
            she was a pioneer of computer programming who invented one of the first compiler related tools.
            She popularized the idea of machine-independent programming languages, which led to the development of COBOL,
            an early high-level programming language still in use today.`,
                            bornAt: '1815-12-10T00:00:00.000Z',
                            diedAt: '1852-11-27T00:00:00.000Z'
                        }
                    ]
                }
            }
        },
        components: { Builder },
        mounted() {},
        methods: {
            handleShow(type, pageId) {
                this.show = true;
                this.pageType = type;
                this.pageId = pageId;
            },
            handleClose() {
                this.show = false;
            },
            goBuilder() {
                /*this.$router.push({
                    name: 'builder',
                    query: { pageType: 2 }
                });*/
                this.handleShow(2)
            },
            goH5(id) {
                /*this.$router.push({
                    name: 'builder',
                    query: { id: 106 }
                });*/
                this.handleShow(2, id)
            },
            goBuilderPc() {
                /*this.$router.replace({
                    name: 'builder-pc',
                    query: { pageType: 5 }
                });*/
                this.handleShow(5)
            },
            goPc(id) {
                // 350 415 416
                /*this.$router.replace({
                    name: 'builder',
                    query: { id: 70 } // 736
                });*/
                this.handleShow(5, id)
            },
            goBuilderWeb() {
                /*this.$router.push({
                    name: 'builder-web'
                });*/
                this.handleShow(1)
            }
        }
    }
</script>
<style lang="scss" scoped>
.home {
    padding: 30px;
    text-align: center;
}
</style>
